def partition(numbers, number):
    list1 = []
    list2 = []
    for i in numbers:
        if i < number:
            list1.append(i)
        else:
            list2.append(i)
    numbers.clear()
    numbers.extend(list1)
    numbers.append(number)
    numbers.extend(list2)
    return len(list1)

def main():
    numbers = [ eval(x) for x in input().split() ]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str,numbers)))
    print(index)
    
if __name__ == "__main__":
    main()
